TARGET=pycpp.so

OS_TYPE=$(shell uname -s)
ifeq ($(OS_TYPE),Darwin)
	BOOST_PYTHON_INC_DIR+=$(HOME)/dev/third/boost_1_72_0
	BOOST_PYTHON_LIB_DIR+=$(HOME)/dev/third/boost_1_72_0/stage/lib
	BOOST_PYTHON_LIBS+=boost_python37
	LDLIBS += -headerpad_max_install_names
else
	BOOST_PYTHON_INC_DIR+=$(HOME)/dev/third/boost_1_70_0
	BOOST_PYTHON_LIB_DIR+=$(HOME)/dev/third/boost_1_70_0/stage/lib
	BOOST_PYTHON_LIBS+=boost_python36
endif

INC_DIR += $(BOOST_PYTHON_INC_DIR)
LIB_DIR += $(BOOST_PYTHON_LIB_DIR)
DEP_LIBS += $(BOOST_PYTHON_LIBS)

CXXFLAGS += $(addprefix -I, $(INC_DIR))
CXXFLAGS += -fPIC -std=c++11 -Wall -g
CXXFLAGS += $(shell python-config --includes)

LOADLIBES += $(addprefix -L, $(LIB_DIR))
LOADLIBES += $(shell python-config --ldflags)

LDLIBS += $(addprefix -l, $(DEP_LIBS))
LDLIBS += -shared 

SRC=$(wildcard *.cpp)
OBJS=$(SRC:.cpp=.o)

all: $(TARGET)

$(TARGET):$(OBJS)
	$(LINK.cpp) $^ $(LOADLIBES) $(LDLIBS) -o $@
ifeq ($(OS_TYPE),Darwin)
	install_name_tool -add_rpath $(BOOST_PYTHON_LIB_DIR) $(TARGET) #for mac
endif
	#python main.py

run: $(TARGET)
	python main.py

clean:
	rm -frv $(OBJS) $(TARGET)
